Sync registered model aliases via SetAlias/DeleteAlias in direct mode#4637
Sync registered model aliases via SetAlias/DeleteAlias in direct mode#4637varundeepsaini wants to merge 1 commit intodatabricks:mainfrom
Conversation
ab92b8b to
034aac0
Compare
|
|
||
| // The Create API does not apply aliases, so we sync them separately. | ||
| if err := r.syncAliases(ctx, response.FullName, config.Aliases, nil); err != nil { | ||
| return "", nil, fmt.Errorf("failed to sync aliases: %w", err) |
There was a problem hiding this comment.
Do we need to wrap the error? Our errors already printed with context such as API endpoint.
| remote, err := r.DoRead(ctx, id) | ||
| require.NoError(t, err) | ||
|
|
||
| assert.Len(t, remote.Aliases, 2) |
There was a problem hiding this comment.
Can these be rewritten as acceptance test? You can capture requests there, run them against cloud, and also read remote state with databricks CLI.
|
|
||
| func (r *ResourceRegisteredModel) DoUpdate(ctx context.Context, id string, config *catalog.CreateRegisteredModelRequest, _ Changes) (*catalog.RegisteredModelInfo, error) { | ||
| // Fetch current remote state to determine which aliases to add/remove. | ||
| remote, err := r.client.RegisteredModels.Get(ctx, catalog.GetRegisteredModelRequest{ |
There was a problem hiding this comment.
As a general guideline, DoUpdate should not read remote state. We already have it in the framework and we can pass it if it's needed. However, in this case we can probably get by reading passed Changes?
034aac0 to
cf22e16
Compare
cf22e16 to
86d4e85
Compare
86d4e85 to
1300e29
Compare
simonfaltum
left a comment
There was a problem hiding this comment.
Review (automated, 2 agents)
Verdict: Not ready yet | 1 Critical | 2 Major | 2 Gap(Major) | 2 Nit | 2 Suggestion
[Critical] Alias ordering causes infinite drift (never converges)
bundle/direct/dresources/registered_model.go (syncAliases)
syncAliases converts slices to maps, destroying order. RemapState returns aliases as-is from the backend. Without KeyedSlices() for aliases, the planner compares by index. If the backend returns aliases in a different order, direct mode plans updates forever. The acceptance test sorts aliases with sort_by(.alias_name), masking this.
Suggestion: Implement KeyedSlices() keyed by alias_name, or sort aliases consistently in RemapState. Add an idempotence test (unchanged redeploy is a no-op).
[Major] DoCreate/DoUpdate return stale state (aliases missing)
bundle/direct/dresources/registered_model.go:72,112
Both methods return the API response captured before syncAliases runs. The Create API doesn't apply aliases and the Update request sets Aliases: nil, so saved deployment state will have aliases: null. System self-heals on next deploy via DoRead, but bundle summary will show stale data.
Suggestion: After syncAliases, do a final DoRead, or merge aliases into the response before returning.
[Major] syncAliases failure after model mutation leaves diverged state
bundle/direct/dresources/registered_model.go:68-70,109-112
If SetAlias/DeleteAlias fails after the model is already created/updated, the workspace is mutated but the state file is unchanged. On create, this leaves an untracked registered model.
Suggestion: Move alias reconciliation to a post-save hook, or persist state before running alias side effects.
[Gap (Major)] No test for DoUpdate with Changes parameter
bundle/direct/dresources/registered_model_test.go
The primary production update path (changes.HasChange(pathAliases)) is not tested. Tests exercise syncAliases directly but not the Changes gating logic.
[Gap (Major)] No idempotence test (unchanged redeploy)
acceptance/bundle/resources/registered_models/aliases/script
Test only redeploys after config changes. Never verifies an unchanged deploy is a no-op.
[Nit] Unnecessary remote fetch in DoCreate
Model was just created, aliases are guaranteed empty. Pass empty slice instead of nil to avoid wasted API call.
[Nit] pathAliases variable style
Use var (...) block with descriptive comment, matching model_serving_endpoint.go pattern.
[Suggestion] Error wrapping in syncAliases
Wrap errors with context: fmt.Errorf("syncing aliases for %s: %w", fullName, err)
[Suggestion] Unnecessary remote fetch in DoCreate
Pass []catalog.RegisteredModelAlias{} instead of nil to skip the GET call.
1300e29 to
d04fd1f
Compare
|
have made the changes had a few thoughts on
|
d04fd1f to
d08815a
Compare
Signed-off-by: Varun Deep Saini <varun.23bcs10048@ms.sst.scaler.com>
d08815a to
4256d01
Compare
|
An authorized user can trigger integration tests manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
|
No, don't add the extra API call. You're right that nothing references |
|
@denik Would you do the final approval since you did the original review? |
Fixes #4012
Summary
aliasesfield on registered models, so aliases defined in bundle config were silently not applied in direct deployment mode.SetAlias/DeleteAliasAPI calls.IncludeAliaseson read so drift detection picks up alias changes.Test plan
TestAll/registered_modelsCRUD test passes